{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 实验室报告 HUNTERXHUNTER 酷拉皮卡无名指测谎链分析"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```\n",
    "初始操作人:调查员12号 调查员汤姆丁\n",
    "最后操作人:调查员12号 调查员汤姆丁\n",
    "实验类型: 神秘现象研究\n",
    "测算时间 : 2020/8/23 14:32\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1.关于实验\n",
    "## 1.1 实验背景\n",
    "酷拉皮卡的无名指测谎链具有识别谎言的能力，将比杨德团队中企图混入黑鲸号的成员全部排除出猎人考试，现在实验室接到委托，要求调查其能力的准确性。实验室通过特殊渠道获得，请从中分析得出有用的信息。(数据真实性不可考，仅供参考)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![jupyter](./photo/timg.jpg)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.2 实验数据"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "假设被测试人员为撒谎状态为事件A, P(A) = 0.05。假设酷拉皮卡锁链报警(晃动)为事件B <br />\n",
    "根据实验数据已知如下内容: <br />\n",
    "$P(B|A)$ = 0.99 <br />\n",
    "$P(B^c|A)$ = 0.01 <br />\n",
    "$P(B|A^c)$ = 0.10 <br />\n",
    "$P(B^c|A^c)$ = 0.90"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1.3 来自V5的关键提问\n",
    "1. 酷拉皮卡锁链晃动的概率为多少?\n",
    "2. 酷拉皮卡锁链晃动并且被测试人员为撒谎状态的概率为多少?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2. 实验过程"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2.1 实验过程 以下根据实验室操作员录音整理"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "实验室提示音: 调查员12号进入实验室<br /> 2020/8/23 14:32 <br /><br />\n",
    "实验室提示音: 调查员汤姆丁进入实验室<br /> 2020/8/23 14:32 <br /><br />\n",
    "调查员汤姆丁: 这实验室最近是咋的了，有钱了，业务接的是越来越花招百出了<br /> 2020/8/23 14:34<br /><br />\n",
    "调查员12号: 前一阵子那个头被干掉了，之前他把业务规划的太窄了，上面那帮老家伙们不同意，只能说现在的业务范围才是实验室原本的水平<br /> 2020/8/23 14:34<br /><br />\n",
    "调查员汤姆丁: 但是今天测试的这个，这不是漫画吗<br /> 2020/8/23 14:39<br /><br />\n",
    "调查员12号: 我只能说，这里的一切真真假假虚实不定，千万不要放松警惕，谁知道这个测试背后的故事是什么，林中小屋团队的覆灭就是小心大意，咱们两个小喽啰就干咱们自己的活就好了<br /> 2020/8/23 14:40<br /><br />\n",
    "调查员12号: 而且重中之重，这个实验室有录音，上次我就是因为录音实验不及格了，废话别那么多了<br /> 2020/8/23 14:42<br /><br />\n",
    "调查员汤姆丁: 我就随口问一句，要是看字数肯定你说的多<br /> 2020/8/23 14:42<br /><br />\n",
    "调查员12号: YOU MTFK<br /> 2020/8/23 14:43<br /><br />\n",
    "调查员汤姆丁: 嘘<br /> 2020/8/23 14:43<br /><br />"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.2 实验报告内容"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "关于V5的第一个问题，即酷拉皮卡锁链晃动的概率是多少，其实是在求$P(B)$，由公式可知$P(B)=P(A^C\\bigcap B) + P(A\\bigcap B)$ <br />\n",
    "$P(A^C\\bigcap B) = P(A^c)P(B|A^c)$ <br />\n",
    "$P(A\\bigcap B) = P(A)P(B|A)$ <br />\n",
    "$P(A^C) = 1 - P(A)$ <br />\n",
    "将数据代入公式计算可得"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "P(A)的补集概率为: 0.95\n"
     ]
    }
   ],
   "source": [
    "PA = 0.05\n",
    "PAc = 1 - PA\n",
    "print('P(A)的补集概率为:',PAc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "锁链晃动的概率为 0.14450000000000002\n"
     ]
    }
   ],
   "source": [
    "PAc_B = PAc * 0.1\n",
    "PA_B = PA * 0.99\n",
    "PB = PAc_B + PA_B\n",
    "print('锁链晃动的概率为',PB)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "若求锁链晃动并且当时测试人员为撒谎的概率，即求$P(A|B)$，由贝叶斯公式可得$P(A|B)=P(A \\bigcap B)/P(B)$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第二个问题的概率是: 0.34256055363321797\n"
     ]
    }
   ],
   "source": [
    "answer = PA_B/PB\n",
    "print('第二个问题的概率是:',answer)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3. 实验结论"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "关于V5的第一个问题，即酷拉皮卡锁链晃动的概率为14.45% <br />\n",
    "关于第二个问题，锁链晃动并且测试人员为撒谎的概率为34.26% <br />\n",
    "但是根据酷拉皮卡在黑鲸号上的筛选表现，所有的比杨德安插的人员全都被排除出猎人通过名单了，所以十分怀疑数据真实性"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 4. 导师批语"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "二维异常事件导师奥斯洛理: 知道实验室录音这次还说话，两个人都不及格 <br />\n",
    "2020/8/24 08:35"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
